/*
 * Created by guoyh on Thu Jan 05 2023 17:37:19
 * leetcode NO.27 https://leetcode.cn/problems/remove-element/ 
 */
#include <iostream>
#include <gtest/gtest.h>
#include<vector>

using namespace std;

class Solution {
public:
    int removeElement(vector<int>& nums, int val) {
        int size = nums.size();
        for(int i = 0; i < size; i++){
            if(*(nums.begin()) == val){
                nums.erase(nums.begin());
            }else{
                nums.push_back(*(nums.begin()));
                nums.erase(nums.begin());
            }
        }
        return nums.size();
    }
};
int add(int a, int b) {
    return a + b;
}

TEST(MyTest, AddTest) {
    EXPECT_EQ(add(1, 2), 3);
}

TEST(MyTest, test01){
    vector<int> v1 = {3,2,2,3};
    Solution slu;
    slu.removeElement(v1, 2);
    ASSERT_EQ(v1.size(), 2);

}

TEST(MyTest, test02){
    vector<int> v1 = {0,1,2,2,3,0,4,2};
    Solution slu;
    slu.removeElement(v1, 2);
    ASSERT_EQ(v1.size(), 5);

}

int main(int argc, char *argv[]) {
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}


